<template>
  <el-container class="layout-container-demo">
    <el-aside width="200px">
      <el-scrollbar>
        <el-menu :default-openeds="['1']" :default-active="'1-1'">
          <el-sub-menu index="1">
            <template #title>
              <el-icon>
                <icon-menu />
              </el-icon>首页
            </template>
            <el-menu-item-group>
              <!-- <template #title>首页</template> -->
              <el-menu-item index="1-1" @click='clickbar("1-1")'>首页</el-menu-item>
            </el-menu-item-group>
            <el-menu-item-group title="分栏">
              <el-menu-item index="1-2" @click='clickbar("1-2")'>列表</el-menu-item>
              <el-menu-item index="1-3" @click="clickbar('1-3')" >详情</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>
          
        </el-menu>
      </el-scrollbar>
    </el-aside>

    <el-container>
      <el-header class="toolbar">
        欢迎来到我的页面
      </el-header>

      <el-main>
        <el-scrollbar>
          <router-view></router-view>
        </el-scrollbar>
      </el-main>

      <el-footer class="footer">
        <p>版权所有 © 2024</p>
      </el-footer>
    </el-container>
  </el-container>
</template>

<script lang="js" setup>
import { ref } from 'vue'
import { Menu as IconMenu, Message, Setting } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
const router = useRouter()// 获取路由实例

const first = ref(null)

const clickbar = (data) => {
  if (data == '1-1') {
    router.push('/')
    console.log('1-1');
  } else if (data == '1-2') {
    router.push('/list')
    console.log('1-2');
  }else if(data == '1-3'){
    router.push('/about')
    console.log('1-3');
  } else {
    console.log('error')
  }

}


</script>



<style scoped>
.layout-container-demo {
  height: 100vh;
  width: auto;
  position: relative;
}

.layout-container-demo .el-header {
  position: relative;
  background-color: var(--el-color-success-light-3);
  color: var(--el-text-color-primary);
}

.layout-container-demo .el-aside {
  color: var(--el-text-color-primary);
  background: var(--el-color-primary-light-9);
}

.layout-container-demo .el-menu {
  border-right: none;
}

.layout-container-demo .el-main {
  padding: 0;
}

.layout-container-demo .toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: larger;
}

/* .layout-container-demo .footer {
  position: relative;
  background-color: var(--el-color-primary-light-7);
  color: var(--el-text-color-primary);
  text-align: center;
} */
.el-footer {
  background-color: #B3C0D1;
  color: #333;
  text-align: center;
  padding: 10px;
}
</style>
